package com.ctcc.pojo

import com.fasterxml.jackson.annotation.JsonIgnoreProperties
import com.fasterxml.jackson.annotation.JsonProperty
import java.util.*


/**
 * "success": true,
"errorCode": 0,
"error": null
 */


/**
 * Created by Peanut on 2018/2/7.
 * form data from webhook
 */
@JsonIgnoreProperties(ignoreUnknown = true)
data class FormData(@JsonProperty("success") val success: Boolean,
                    val errorCode: Int,
                    val error: Any?,
                    val data: DataWrapper
)

@JsonIgnoreProperties(ignoreUnknown = true)
data class DataWrapper( val formInfo: FormInfo
                       /*val basicInfo: HashMap<String, Any>*/)


@JsonIgnoreProperties(ignoreUnknown = true)
data class FormInfo(
        @JsonProperty("widgetMap") val widgetMap: HashMap<String, Widget>,
        @JsonProperty("detailMap") val detailMap: HashMap<String, Detail>?
)


@JsonIgnoreProperties(ignoreUnknown = true)
data class Detail(

        @JsonProperty("codeId") val codeId: String,
        @JsonProperty("title") val title: String,
        @JsonProperty("widgetValue") val widgetValue: List<WidgetValue>

)


@JsonIgnoreProperties(ignoreUnknown = true)
data class Widget(
        @JsonProperty("codeId")  val codeId: String,
        @JsonProperty("extendFieldMap")  val extendFieldMap: HashMap<String, Any>?,
        @JsonProperty("title")  val title: String,
        @JsonProperty("type")  val type: String,
        @JsonProperty("value")  val value: Any?,
        @JsonProperty("options")  val options: List<Option>?,
        @JsonProperty("personInfo")  val personInfo: List<PersonInfo>?)


@JsonIgnoreProperties(ignoreUnknown = true)
data class Option(
        @JsonProperty("checked") val checked: Boolean,
        @JsonProperty("value")   val value: String,
        @JsonProperty("key")     val key: String)


@JsonIgnoreProperties(ignoreUnknown = true)
data class PersonInfo(
        @JsonProperty("image")  val image: String,
        @JsonProperty("name")   val name: String,
        @JsonProperty("oid")    val oid: String,
        @JsonProperty("userId") val userId: String
)

/*"Mo_1": "60",
"Te_2": "好便宜",
"Ra_0": "AaBaCcDd",
"Mo_0": "100",
"_id_": "1",
"Ac_0": "0.60"*/
@JsonIgnoreProperties(ignoreUnknown = true)
data class WidgetValue(
        @JsonProperty("Mo_1")  val Mo_1: String?,
        @JsonProperty("Te_2") val Te_2: String?,
        @JsonProperty("Ra_0") val Ra_0: String?,
        @JsonProperty("Mo_0")  val Mo_0: String?,
        @JsonProperty("_id_") val _id_: String?,
        @JsonProperty("Ac_0") val Ac_0: String?
)
